#pragma once 
#include <string> 
#include <cstddef> 
#include <memory>
#include <odb/nullable.hxx>
#include <odb/core.hxx>

namespace zhiang {

#pragma db object table("vlog")
class Vlog {
public:
    Vlog() {}
    Vlog(const std::string& vlog_id,  const std::string& user_id) :
        _vlog_id(vlog_id), _user_id(user_id) {}

    std::string vlog_id() { return _vlog_id; }
    void vlog_id(const std::string& val) {  _vlog_id = val; }

    boost::posix_time::ptime create_time() { return _create_time; }
    void create_time(const boost::posix_time::ptime& val) {  _create_time = val; }

    std::string title() { return _title; }
    void title(const std::string& val) {  _title = val; }

    std::string intro() { return _intro; }
    void intro(const std::string& val) {  _intro = val; }

    std::string link() { return _link; }
    void link(const std::string& val) {  _link = val; }

    unsigned int view_count() const { return _view_count; }
    void view_count(const unsigned int& val) {  _view_count = val; }


    std::string user_id() {
        if(!_user_id) return "";
        return *_user_id;
    }
    void user_id(const std::string& val) { _user_id = val; }
private:
    friend class odb::access;
    #pragma db id auto
    unsigned int _id;
    #pragma db index
    unsigned int _view_count;
    #pragma db type("varchar(64)") index unique
    std::string _vlog_id;
    #pragma db not_null type("timestamp") index
    boost::posix_time::ptime _create_time;
    #pragma db type("varchar(128)") 
    std::string _title;
    #pragma db type("varchar(256)") 
    std::string _link;
    #pragma db type("varchar(512)") 
    std::string _intro;
    #pragma db type("varchar(128)") index
    odb::nullable<std::string> _user_id;
};

}